home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / gus / sdkdigv2.zip / SDKV2N10.TXT next >
Text File  |  1993-06-23  |  8KB  |  247 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. GUS Programmer's Digest     Sat Jun 12 00:07     Volume 2: Issue  10  
  7.  
  8. Today's Topics:
  9.                       Double buffering algorithm
  10.               Looping and wave table generation problems
  11.                    Turbo Pascal SDK alpha release.
  12.  
  13. Standard Info:
  14.     - Meta-info about the GUS can be found at the end of the Digest.
  15.     - Before you ask a question, please READ THE FAQ.
  16.  
  17. ----------------------------------------------------------------------
  18.  
  19. Date: Fri, 11 Jun 93 10:13:21 EST
  20. From: support@fortech.com (Technical Support)
  21. Subject: Double buffering algorithm
  22. Message-ID: <9306111013.0.UUL1.3#16204@fortech.com>
  23.  
  24. Hi folks,
  25.  
  26. I've been watching the postings the last few days on how to implement a
  27. double buffering scheme of playing digital audio in the GUS. It is actually
  28. quite simple, but I guess I didn't explain it very well in the SDK. 
  29. I'll give a brief description here and I'll try and work up a simple 
  30. example over the weekend. (no promises, I'm kinda busy ....)
  31. I'll use small numbers for illustrative pruposes. Your buffers would 
  32. normally be much larger. (This example doesn't worry about start up 
  33. conditions like not enough data to fill buffers, or exactly what happens at 
  34. the end when you run out of data.)
  35.  
  36. 1) Probe for card
  37.  
  38. 2) Open Card.
  39.  
  40. 3) Allocate a chunk of DRAM. Lets say it ends up at locations 1000 to 2000.
  41.  
  42. 4) Allocate a voice (assume mono. stereo just confuses the issue)
  43.  
  44. 5) Set up a callback for wave table IRQ's
  45.  
  46. 6) Read in 1000 bytes of data and send it to the card.
  47.  
  48. 7) Start up the voice with looping on, uni-directional, irqs enabled with the
  49.    begin = 1000, start = 1000 and end = 1500. Also turn on the rollover bit
  50.    on the volume control register for this voice. This setup will start the
  51.    voice up and will generate an IRQ at location 1500. However, the voice
  52.    will NOT loop yet. The rollover bit takes precedence.
  53.  
  54. 8) Wait until your foreground code is told it can load a buffer. (See how the
  55.    callback is defined below.
  56.  
  57.  
  58.  
  59. 9) If filling buffer 0, load 500 bytes into 1000-1500.
  60.    If filling buffer 1, load 500 bytes into 1500-2000.
  61.  
  62. 10) Goto step #8 till data is gone.
  63.  
  64. 11) Stop voice
  65.     Free memory.
  66.     Free Voice.
  67.     Close card.
  68.  
  69.  
  70. CALLBACK
  71. ========
  72. 1) If you just played buffer 0 (1000-1500), turn OFF the rollover bit and
  73.    set the voice end address to 2000. (This is so when the voice hits 2000, it
  74.    will loop back to 1000 and generate an IRQ.) Also tell the foreground that
  75.    the first buffer can now be filled with new data (1000-1500). This might
  76.    be done by setting a flag that the foreground checks.
  77.  
  78.    If you just played buffer 1 (1500-2000), turn ON the rollover bit and set
  79.    set the voice end address to 1500. (This is so when the voice hits 1500,
  80.    it will generate and IRQ and continue without looping) Also tell the
  81.    forground that the second buffer can now be filled with new data (1500-2000).
  82.    This might be done by setting a flag that the forground checks.
  83.  
  84. ===============================================================================
  85. Thats about all there is to it. I've left out some the the implementation
  86. details, but thats the basic flow of the logic.
  87.  
  88. The above method is useful if you have some control over how much data you
  89. are going to get and when you can get it. If the data is coming to you is
  90. random in length and is under some other applications control, some other
  91. considerations come into play. I don't have time to give an example of it
  92. right now, but it mainly has to do with tacking the data onto the end of
  93. data that is playing and moving the end address to the end of the new data.
  94. When you hit the end of the allocated DRAM buffer, send as much data as you can
  95. to fill the buffer and turn on the loop bit with IRQ. Send the remaining data
  96. down to the beginning of the buffer. When the IRQ comes in, turn the looping off
  97. and set the new end address to the end of the remaining data that you put
  98. at the beginning of the buffer. Sounds complex, but really isn't too bad.
  99.  
  100. Gotta go get some work done. Hope this helps. Like I said, I'll try and work
  101. up a simple example, but I can't promise it'll be done over the weekend.
  102.  
  103. Forte Tech. Support.
  104.  
  105. ------------------------------
  106.  
  107. Date: Fri, 11 Jun 93 12:20:43 EDT
  108. From: davidm@opl.com
  109. Subject: Looping and wave table generation problems
  110. Message-ID: <AFC480DC-80DD0001@woodstock.opl.com>
  111.  
  112.  
  113.  
  114. Hi, GUS Programmers,
  115.  
  116. I have writen a simple program that downloads a sine wave with varying 
  117. amplitude to the GUS' DRAM and then plays it.  I have been experimenting
  118. with looping and wave table IRQ generation/handling.  It's pretty straight
  119. forward stuff.
  120.  
  121. The problem I have is that when I enable wave table IRQ's, I get one IRQ,
  122. but no looping even though looping is enabled.  This is true with either
  123. uni-directional or bi-directional looping.  Am I doing something wrong 
  124. (likely) or is this a bug in the SDK (not likely).  BTW, I am using the low
  125. level SDK version 2.01.
  126.  
  127. Below I have included the relevant parts of my program.  If it is 
  128. compiled with USEIRQS defined, it plays the wave once and stops and one
  129. audible bell character is heard.  If it is compiled without USEIRQS defined,
  130. everything works exactly as expected (i.e. the wave loops until a key is
  131. pressed).
  132.  
  133. This is very puzzling to me.  If anyone has any thoughts about what is going
  134. on here, I would love to hear them.
  135.  
  136. Thanks,
  137. Dave
  138.  
  139. David MacMahon
  140. Systems Administrator
  141. davidm@opl.com
  142.  
  143. ---------------------
  144.  
  145. // VOIce Control Bits (from appendix C of LOWSRC.DOC v2.01)
  146. #define VOICB_8BIT    0
  147. #define VOICB_16BIT   4
  148. #define VOICB_NOLOOP  0
  149. #define VOICB_LOOP    8
  150. #define VOICB_UNIDIR  0
  151. #define VOICB_BIDIR   16
  152. #define VOICB_NOWTIRQ 0
  153. #define VOICB_WTIRQ   32
  154.  
  155. // Global variable
  156. int irqcount;
  157.  
  158. void HandleWave( int voice_num)
  159. {
  160.     irqcount++;
  161. }
  162.  
  163. void main()
  164. {
  165.    .
  166.  
  167.  
  168.    . [initialization, wave generation and download code deleted]
  169.    .
  170.  
  171. // Grab the wave handler
  172. OldWaveHandler = UltraWaveHandler( HandleWave);
  173.  
  174. #ifdef USEIRQS
  175. LoopType = VOICB_LOOP | VOICB_UNIDIR | VOICB_WTIRQ;
  176. #else
  177. LoopType = VOICB_LOOP | VOICB_UNIDIR | VOICB_NOWTIRQ;
  178. #endif
  179.  
  180. // Start voice
  181. UltraStartVoice(
  182.     voice_num,
  183.     Begin,
  184.     Start,
  185.     End,
  186.     VOICB_8BIT | LoopType);
  187.  
  188. // Wait
  189. printf( "Playing...  Press any key to quit.");
  190. while( !kbhit())
  191. {
  192.     if( irqcount)
  193.     {
  194.         // If there have been wave table IRQ's,
  195.         // beep PC speaker and reset IRQ counter
  196.         printf("\a");
  197.         irqcount = 0;
  198.     }
  199. }
  200.  
  201.    .
  202.    . [clean-up code deleted]
  203.    .
  204.  
  205. }
  206.  
  207. ------------------------------
  208.  
  209. Date: Fri, 11 Jun 93 15:00 EDT
  210. From: "Matthew E. Bernold" <MEB117@PSUVM.PSU.EDU>
  211. Subject: Turbo Pascal SDK alpha release.
  212. Message-ID: <9306111859.AA13489@orca.es.com>
  213.  
  214. Is anyone out there interested in a Pascal translation of the SDK?  I have
  215. succeeded in translating about half of the SDK directly from C to Pascal,
  216. and am looking for some testers.  If you are interested, please E-mail me
  217. directly.  Once I get all the functions translated, I will release a full
  218. beta version on Epas, but for now, I'd like to try a limited distribution.
  219.  
  220. Also, I'm having a few difficulties in some of the translation problems.
  221.  
  222.  
  223. If anyone out there is fluent in both C and Pascal, and has experience with
  224. interrupt handlers and DMA stuff, please drop me a line so I can ask a few
  225. questions and get this thing finished.
  226.  
  227.        Matthew E. Bernold             MEB117@PSUVM.PSU.EDU
  228.          <<APOCALYPSE>>                  meb@wilbur.cac.psu.edu
  229.  
  230. ------------------------------
  231.  
  232. End of GUS Programmer's Digest V2 #10
  233. *************************************
  234.  
  235. To post to tomorrow's digest:               <gus-sdk%itchy@dsd.es.com>
  236. To (un)subscribe or get help:       <gus-sdk-request%itchy@dsd.es.com>
  237. To contact a human (last resort):     <gus-sdk-owner%itchy@dsd.es.com>
  238.  
  239. FTP sites:         archive.epas.utoronto.ca         pub/pc/ultrasound
  240.                    wuarchive.wustl.edu       systems/msdos/ultrasound
  241. Hints:
  242.       - Get the FAQ from the FTP sites or the request server.
  243.       - Mail to <gus-sdk-request%itchy@dsd.es.com> for info about
  244.     other GUS related mailing lists (UNIX, OS/2, GUS-MIDI, etc.)
  245.  
  246.  
  247.